<?php

if (!defined("BASEPATH"))
    exit("No direct script access allowed");
require_once APPPATH . "controllers/dienhoa-administrator/base_controller" . EXT;

class Comment extends Base_controller{
    
    public function __construct() {
        parent::__construct();
        $this->load->model("com_model");
    }
    
    public function xu_ly_cm(){
        $this->permissions_view();
        $data = array();
        $data = $this->SetMenu("SanPham");
        $data["cm_infor"] = $this->com_model->getAllCom()->result();
        $fid = $this->uri->segment(4);
//        $fid= $this->input->post("fid");
        if($fid){
            $data["cm_fid"] = $this->com_model->getCom($fid)->result();
            if(IS_AJAX){
               $this->load->view("admin/comment/cm_view_ajax",$data);
            }else{
                $this->render($this->load->view("admin/comment/comment_view",$data,TRUE));
            }
        }  else {
            $this->render($this->load->view("admin/comment/comment_view",$data,TRUE));
        }
    }
    
    //xoa comment
    public function xoa_phan_hoi(){
        $this->permission_del_edit();
        
        $fid = $this->uri->segment(5);
        $cmid = $this->uri->segment(4);
        $rs = $this->com_model->delCom($cmid);
        if($rs){
            $data["cm_fid"] = $this->com_model->getCom($fid)->result();
            $this->load->view("admin/comment/cm_view_ajax",$data);
        }else{
            echo "1";
        }
    }
}
?>
